<template>
  <div class="Home-Hot">
    <!--分类-->
    <div class="Home-CategoryList">
      <div class="list-item" v-for="type in typeShowList" :key="type.id">
        <div class="Home-CategoryLabel" @click="toTypePage(type)">{{ type.label }}</div>
      </div>
    </div>
    <!--视频区-->
    <div class="layout-Floor" v-for="item in typeShowList">
      <div class="Home-BlockTitle">
        <div class="BlockTitle-Label">
          {{ item.label }}
          <!--子分类列表-->
          <div class="Home-Btn right-margin" @click="toTypePage(typeItem)" v-for="typeItem in item.children.slice(0,4)">
            {{ typeItem.label }}
            <i class="el-icon-arrow-right"></i>
          </div>
        </div>
        <div class="Home-Btn" @click="toTypePage(item)">
          更多
          <i class="el-icon-arrow-right"></i>
        </div>
      </div>
      <!--视频分类-->
      <div class="block-list">
        <div class="Home-CoverList">
          <!--判断视频是否存在-->
          <template v-if="item.videos.length>0">
            <!--VideoList展示-->
            <div class="Home-CoverItem" v-for="video in item.videos" @click="toVideoPage(video)">
              <div class="videoIcon cursor">
                <img :src="video.coverPath|imgSrcFormat" alt="">
                <div class="playIcon">
                  <i class="el-icon-video-play"></i>
                </div>
                <div class="video-icon-label">
                  <div class="icon">
                    <div class="iconfont icon-tuya-"></div>
                    <div>{{ video.views|numberFilter }}</div>
                  </div>
                  <div class="icon">
                    <div class="iconfont icon-dianzan_kuai"></div>
                    <div>{{ video.likes|numberFilter }}</div>
                  </div>
                </div>
              </div>
              <div class="info cursor">
                <div class="Cover-Title">{{ video.title }}</div>
              </div>
            </div>
          </template>
          <div class="unData" v-if="item.videos.length===0">
            <el-empty description="暂无数据"></el-empty>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import videoApi from "@/api/video";

export default {
  name: "All",
  data() {
    return {
      /*展示的类型*/
      typeShowList: [],
      /*更多中的类型*/
      typeMoreList: []
    };
  },
  methods: {
    /*获取类型列表*/
    async getTypeList() {
      let {data: {typeList}} = await videoApi.getDetailTypeInfo();
      if (typeList?.length > 13) {
        this.typeShowList = typeList.slice(0, 13);
        this.typeMoreList = typeList.slice(13);
      } else {
        this.typeShowList = typeList;
      }
    },
    /*跳转到播放页面*/
    toVideoPage(video) {
      this.$router.push({
        name: "details",
        params: {
          videoId: video.id
        }
      });
    },
    /*跳转到分类页面*/
    toTypePage(type) {
      this.$router.push({
        name: "type",
        params: {
          typeId: type.id
        }
      });
    }
  },
  created() {
    this.getTypeList();
  },
  mounted() {

  }
};
</script>

<style scoped lang="less">
.Home-Hot {
  margin: 12px auto;
  width: 1224px;
  /*分类*/

  .Home-CategoryList {
    display: flex;
    align-items: center;

    .list-item {
      padding: 0 10px;

      .Home-CategoryLabel {
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        box-sizing: border-box;
        display: block;
        padding: 3px 5px;
        margin: 10px 0 0;
        border-radius: 2em;
        text-align: center;
        font-weight: 400;
        background-color: #f4f5f9;
        color: #333333;
        cursor: pointer;

        &:hover {
          background-color: #ff5d23;
          color: #ffffff;
        }
      }
    }
  }

  /*视频区*/

  .layout-Floor {
    margin-top: 12px;
    width: 100%;

    .Home-BlockTitle {
      display: flex;
      margin: 20px 0;
      flex-grow: 1;
      align-items: center;

      .BlockTitle-Label {
        text-overflow: ellipsis;
        font-size: 26px;
        margin: 0 6px 0 10px;
        overflow: hidden;
      }

      .right-margin {
        margin-right: 10px;
      }

      .Home-Btn {
        margin-left: auto;
        display: inline-block;
        vertical-align: middle;
        border: 1px solid #d3ded3;
        padding: 2px 10px;
        min-width: 52px;
        border-radius: 10em;
        text-align: center;
        cursor: pointer;
        font-size: 12px;
        color: #999;
        box-sizing: border-box;
        height: 24px;

        &:hover {
          background-color: #ff5d23;
          color: white;

          .el-icon-arrow-right {
            color: white;
          }
        }

        .el-icon-arrow-right {
          color: #ff5d23;
        }
      }
    }

    .block-list {
      width: 100%;

      .Home-CoverList {
        display: flex;
        flex-wrap: wrap;
        flex: 1;

        .Home-CoverItem {
          width: calc(100% / 6 - 12px);
          border-radius: 4px;
          height: 177px;
          margin-right: 12px;
          margin-top: 8px;

          .videoIcon {
            position: relative;
            height: 109px;
            overflow: hidden;

            .playIcon {
              .el-icon-video-play {
                position: absolute;
                left: 50%;
                top: 50%;
                transform: translate(-50%, -50%);
                color: white;
                transition: all .3s ease-in-out;
                display: none;
                font-size: 50px;
              }
            }

            &:hover {
              & > .video-icon-label {
                display: none;
              }

              & > .playIcon > .el-icon-video-play {
                display: inline-block;
                animation-name: scale;
                animation-duration: .3s;
              }
            }

            img {
              width: 100%;
              height: 100%;
            }

            .video-icon-label {
              display: flex;
              position: absolute;
              bottom: 0;
              left: 0;
              padding: 5px 10px;

              .icon {
                font-size: 12px;
                margin-right: 9px;
                color: white;
                display: flex;
                line-height: 16px;

                .iconfont {
                  font-size: 14px;
                  margin-right: 4px;
                }
              }
            }
          }

          .info {
            padding: 6px;

            .Cover-Title {
              min-height: 38px;
              overflow: hidden;
              font-weight: 400;
              text-overflow: ellipsis;
              -webkit-line-clamp: 2;
              font-size: 14px;
              line-height: 19px;
              word-break: break-all;
              transition: .3s;

              &:hover {
                color: #ff5d23;
              }

            }
          }

          &:nth-child(6n) {
            margin-right: 0;
          }
        }

        .unData {

        }
      }
    }
  }
}

@keyframes scale {
  from {
    font-size: 200px;
  }
  to {
    font-size: 50px;
  }

}
</style>
